Learn R Programming

Compositional (version 1.5)

Multivariate normal random values simulation: Multivariate normal random values simulation

Description

Multivariate normal random values simulation.

Usage

rmvnorm(n, mu, sigma)

Arguments

n
The sample size, a numerical value.
mu
The mean vector in $R^d$.
sigma
The covariance matrix in $R^d$.

Value

A matrix with the simulated data.

Details

The algorithm uses univariate normal random values and transforms them to multivariate via a spectral decomposition. It is slower than the command mvrnorm available from MASS, but it allows for singular covariance matrices. This function is used by rcompnorm.

References

Aitchison J. (1986). The statistical analysis of compositional data. Chapman & Hall.

See Also

comp.den, rdiri, rmvt

Examples

Run this code
x <- as.matrix(iris[, 1:2])
m <- colMeans(x)
s <- var(x)
y <- rmvnorm(100, m, s)
colMeans(y)
var(y)

Run the code above in your browser using DataLab